package com.longrise.android.byjk.plugins.hra.hratabfirst;

import com.longrise.LEAP.Base.Objects.EntityBean;
import com.longrise.android.byjk.common.UrlConstants;
import com.longrise.android.loaddata.newloaddata.LoadDataManagerFather;
import com.longrise.common.datasource.remote.LoadDataManager;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/1/3.
 */

public class HraOrderPresenter extends HraOrderContract.Presenter  {


    public static final String TAG = "HraOrderPresenter";
    private List<HraOrderDefaultItem> mOrderDefaultItemList = new ArrayList<>();

    @Override
    protected void init() {

    }

    @Override
    public void getDataFromNet(String areaId,String bespeakdate){
        EntityBean bean = new EntityBean();
        bean.set("areaid", areaId);
        bean.set("bespeakdate", bespeakdate);
        EntityBean bean1 = new EntityBean();
        bean1.set("bean", bean);
        LoadDataManager.getInstance().callService2(null, UrlConstants.BaseUrl, "hra_searchStore", bean1, new LoadDataManager.OnRequestCallListener2() {

            @Override
            public void onSuccess(String key, String service, Object result) {
                try {
                    EntityBean bean = (EntityBean) result;
                    mView.refreshData(bean);
//                    parseHraOrderData(result);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }


            @Override
            public void onFinished(String key, String service) {
                mView.setRefreshing(false);
            }

            @Override
            public void onError(String key, String service, LoadDataManagerFather.ResultType resultType) {

            }

        });
    }



    //根据价格筛选服务点
    @Override
    public void getSelectOrderData(String areaId, String bespeakdate, String price) {
        EntityBean bean = new EntityBean();
        bean.set("areaid", areaId);
        bean.set("bespeakdate", bespeakdate);
        bean.set("price", price);
        EntityBean bean1 = new EntityBean();
        bean1.set("bean", bean);
        LoadDataManager.getInstance().callService2(null, UrlConstants.BaseUrl, "hra_modifysearchStore", bean1, new LoadDataManager.OnRequestCallListener2() {

            @Override
            public void onSuccess(String key, String service, Object result) {
                try {
                    EntityBean bean = (EntityBean) result;
                    mView.refreshSelectData(bean);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }


            @Override
            public void onFinished(String key, String service) {
                mView.setRefreshing(false);
            }

            @Override
            public void onError(String key, String service, LoadDataManagerFather.ResultType resultType) {

            }

        });
    }

}
